<!DOCTYPE html>
<head xmlns:v-bind="http://www.w3.org/1999/xhtml">
    <meta charset="UTF-8">
    <title>服务接口管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="../css/font.css">
    <link rel="stylesheet" href="../css/xadmin.css">
    <script type="text/javascript"
            src="../lib/vue/jquery.min.js"></script>
    <script type="text/javascript" src="../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../js/xadmin.js"></script>
    <script type="text/javascript" src="../js/global.js"></script>
    <script type="text/javascript" src="../js/store.js"></script>
    <script type="text/javascript" src="../js/cookies.js"></script>
    <script src="../lib/vue/vue.min.js"></script>
    <script src="../lib/vue/axios.min.js"></script>
    <style>
        .layui-form-select dl {
            max-height: 200px;
        }

        .layui-unselect {
            text-align: left;
        }
    </style>
</head>
<body>

<div   >
    <h1 STYLE="color:grey">欢迎使用组件管理系统!</h1>
</div>
</body>
<!--<body>
<div id="summary">
    <div class="layui-row">
        <div class="layui-col-md10">
            <div class="x-body layui-anim layui-anim-up">
                <div>
                    <blockquote class="layui-elem-quote">
                        <div style="width: 300px;">
                            <form class="layui-form">
                                <select id="selectPid" name="projectId" lay-filter="selectPid">
                                </select>
                            </form>

                        </div>
                    </blockquote>
                    <hr class="layui-bg-red">
                </div>
                <fieldset class="layui-elem-field">
                    <legend>项目概要</legend>
                    <div class="layui-field-box">
                        <div class="layui-col-md12">
                            <div class="layui-card">
                                <div class="layui-card-body">
                                    <div class="layui-carousel x-admin-carousel x-admin-backlog"
                                         lay-anim="" lay-indicator="inside" lay-arrow="none"
                                         style="width: 100%; height: 90px;">
                                        <div carousel-item="">
                                            <ul class="layui-row layui-col-space10 layui-this">
                                                <li class="layui-col-xs3">
                                                    <a href="javascript:;"
                                                       class="x-admin-backlog-body">
                                                        <h3>项目类型</h3>
                                                        <p>
                                                            <cite>{{projectInfo.projectType |
                                                                convertType }}</cite>
                                                        </p>
                                                    </a>
                                                </li>
                                                <li class="layui-col-xs3">
                                                    <a href="javascript:;"
                                                       class="x-admin-backlog-body">
                                                        <h3>版本号</h3>
                                                        <p>
                                                            <cite>V{{projectInfo.projectVersion}}</cite>
                                                        </p>
                                                    </a>
                                                </li>
                                                <li class="layui-col-xs3">
                                                    <a href="javascript:;"
                                                       class="x-admin-backlog-body">
                                                        <h3>最后更新时间</h3>
                                                        <p>
                                                            <cite style="font-size: 16px">{{projectInfo.lastUpdateTime
                                                                | convertDate}}</cite>
                                                        </p>
                                                    </a>
                                                </li>
                                                <li class="layui-col-xs3"
                                                    @click="openMenu('#log-menu')">
                                                    <a href="javascript:;"
                                                       class="x-admin-backlog-body">
                                                        <h3>24小时内项目动态</h3>
                                                        <p>
                                                            <cite>{{projectInfo.logCount}}</cite>
                                                        </p>
                                                    </a>
                                                </li>
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md12">
                            <div class="layui-card">
                                <div class="layui-card-body">
                                    <div class="layui-carousel x-admin-carousel x-admin-backlog"
                                         lay-anim="" lay-indicator="inside" lay-arrow="none"
                                         style="width: 100%; height: 90px;">
                                        <div carousel-item="">
                                            <ul class="layui-row layui-col-space10 layui-this">
                                                <li class="layui-col-xs3"
                                                    title="点击查询分组统计"
                                                    @click="openContractCount(projectInfo.id,projectInfo.projectName)">
                                                    <a href="javascript:;"
                                                       class="x-admin-backlog-body">
                                                        <h3>契约总数</h3>
                                                        <p>
                                                            <cite>{{projectInfo.contractCount}}</cite>
                                                        </p>
                                                    </a>
                                                </li>
                                                <li class="layui-col-xs3"
                                                    title="点击查询分组统计"
                                                    @click="openApiCount(projectInfo.id,projectInfo.projectName)">
                                                    <a href="javascript:;"
                                                       class="x-admin-backlog-body">
                                                        <h3>接口总数</h3>
                                                        <p>
                                                            <cite>{{projectInfo.apiCount}}</cite>
                                                        </p>
                                                    </a>
                                                </li>
                                                <li class="layui-col-xs3"
                                                    @click="openMenu('#status-code-menu')">
                                                    <a href="javascript:;"
                                                       class="x-admin-backlog-body">
                                                        <h3>状态码总数</h3>
                                                        <p>
                                                            <cite>{{projectInfo.statusCodeCount}}</cite>
                                                        </p>
                                                    </a>
                                                </li>
                                                <li class="layui-col-xs3"
                                                    @click="openMenu('#partner-menu')">
                                                    <a href="javascript:;"
                                                       class="x-admin-backlog-body">
                                                        <h3>项目成员</h3>
                                                        <p>
                                                            <cite>{{projectInfo.partnerCount}}</cite>
                                                        </p>
                                                    </a>
                                                </li>
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </fieldset>
            </div>
        </div>
        <div class="layui-col-md2">
            <div style="margin-top: 20px;margin-bottom: 10px"><a><i class="iconfont">&#xe6bf;</i>
                项目动态(24小时内)</a></div>

            <ul class="layui-timeline">
                <div v-for="(item,index) in projectInfo.logList">
                    <li class="layui-timeline-item" style="padding-bottom: 0px">
                        <i class="layui-icon layui-timeline-axis">&#xe63f;</i>
                        <div class="layui-timeline-content layui-text">
                            <a class="layui-timeline-title"
                               style="font-size: 12px">{{item.opTime}}</a>
                            <p>
                            <div style="font-size: 10px">{{item.userNickName}}:'{{item.opDesc}}'
                            </div>
                            </p>
                        </div>
                    </li>
                </div>
                <li class="layui-timeline-item">
                    <i class="layui-icon layui-timeline-axis">&#xe63f;</i>
                    <div class="layui-timeline-content layui-text">
                        <div class="layui-timeline-title"><a href="javasrcipt:;" @click="openMenu('#log-menu')">更多</a></div>
                    </div>
                </li>
            </ul>
        </div>
    </div>
</div>
<script>
    let vm = new Vue({
        el: '#summary',
        data () {
            return {
                superFlag: 0,
                projectId: '',
                projectInfo: {}
            }
        },
        methods:{
            openContractCount(projectId, projectName){
                x_admin_show('契约统计', './contract-group-data.html?projectId='
                    + projectId+'&projectName='+ projectName, 800, 400, true)
            },
            openApiCount(projectId, projectName){
                x_admin_show('接口统计', './api-group-data.html?projectId='
                    + projectId+'&projectName='+ projectName, 800, 400, true)
            },
            openMenu(btn){
                $(btn, parent.document).click();
            }
        },
        //过滤器
        filters: {
            convertType (value) {
                return projectTypeArray[value]
            },
            convertDate (value) {
                return dateFormat(value)
            }
        },
        //渲染之前加载cookie数据
        beforeMount () {
            this.superFlag = parseInt(getCookie('superFlag'))
            var url
            if(this.superFlag == 1){
                //超级管理员返回所有正常的项目
                url = _hostUrl + '/projects?projectStatus=1'
            }else{
                // 普通成员查询自己所在的正常的项目列表
                url = _hostUrl + '/projects/normal/'+parseInt(getCookie('userId'))
            }
            axios.get(url).then(response => {
                if (response.data.responseCode == 200) {
                    var projectIds = response.data.data.resultList
                    this.projectId = response.data.data.resultList[0].id
                    setCookie('projectStatus','1')
                    layui.use(['form'], function () {
                        $ = layui.jquery
                        var form = layui.form
                        $.each(projectIds, function (index, item) {
                            $('#selectPid').append(new Option(item.projectName, item.id))
                        })
                        //默认加载第一个
                        $('#selectPid').val(projectIds[0].id)
                        form.render()
                    })
                } else if (response.data.responseCode == 401) {
                    layui.layer.msg('登录已失效', {
                        icon: 2,
                        timeout: 2000
                    }, function () {
                        parent.location.href = '../login.html'
                    })
                }
            }).catch(error=>{
                parent.location.href = '../login.html'
            })

        },
        watch: {
            projectId () {
                axios.get(_hostUrl + '/project/summary/' + parseInt(this.projectId)).then(response => {
                    if (response.data.responseCode == 200) {
                        this.projectInfo = response.data.data
                        setCookie('projectId', this.projectId)
                        setCookie('projectStatus', this.projectInfo.projectStatus)
                    }else if (response.data.responseCode == 401){
                        layui.layer.msg('登录已失效',{
                            icon:2,
                            timeout:2000
                        },function () {
                            parent.location.href = '../login.html'
                        })
                    }
                }).catch(error => {
                    parent.location.href = '../login.html'
                })

            }
        }
    })
</script>-->
<script>
    layui.use(['form', 'layer'], function () {
        $ = layui.jquery
        var form = layui.form
        form.on('select(selectPid)', function (data) {
            vm.projectId = data.value
        })
    })
</script>
</body>
</html>